package com.thinksmart.qfilemanager.widget;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by F3060803 on 2017/6/9.
 */

public class listItem implements Parcelable{
    private int resId; //Image resource id
    private String text; //Title text
    private boolean isSelected; //Is checkbox checked
    private boolean isDir; //Is this item is dir or file

    public final static Parcelable.Creator<listItem> CREATOR = new Parcelable.Creator<listItem>() {
        @Override
        public listItem createFromParcel(Parcel source) {
            return new listItem(source);
        }

        @Override
        public listItem[] newArray(int size) {
            return new listItem[size];
        }
    };

    public listItem(Parcel source) {
        resId = source.readInt();
        text = source.readString();
        boolean val[] = new boolean[0];
        source.readBooleanArray(val);
        isSelected = val[0];
        source.readBooleanArray(val);
        isDir = val[0];
    }

    public listItem() {
        isSelected = false;
        isDir = false;
    }

    public void setIcon(int id) {
        resId = id;
    }

    public void setText(String str) {
        text = str;
    }

    public void setCheckBox(boolean selected) {
        isSelected = selected;
    }

    public void setDir(boolean dir) {
        isDir = dir;
    }

    public boolean isItemChecked() {
        return isSelected;
    }

    public boolean isDir() {
        return isDir;
    }

    public int getIcon() { return resId; }

    public String getText() { return text; }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(resId);
        dest.writeString(text);
        dest.writeBooleanArray(new boolean[]{isSelected});
        dest.writeBooleanArray(new boolean[]{isDir});
    }
}
